package com.zcp.todayheadline.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.zcp.todayheadline.FriendsActivity;
import com.zcp.todayheadline.R;
import com.zcp.todayheadline.SearchActivity;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.fragment_care)
public class CareFragment extends Fragment implements View.OnClickListener {

    @ViewInject(R.id.care_imageAdd)
    ImageView care_imageAdd;

    @ViewInject(R.id.care_linFriends)
    LinearLayout care_linFriends;

    @ViewInject(R.id.care_linMore)
    LinearLayout care_linMore;

    boolean inject = false;

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;


    public CareFragment() {
        // Required empty public constructor
    }


    public static CareFragment newInstance(String param1, String param2) {
        CareFragment fragment = new CareFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        inject = true;


        return x.view().inject(this, inflater, container);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (!inject) {
            x.view().inject(this, this.getView());
        }
        care_imageAdd.setOnClickListener(this);
        care_linFriends.setOnClickListener(this);
        care_linMore.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.care_imageAdd:
                startActivity(new Intent(getActivity(), SearchActivity.class));
                break;
            case R.id.care_linFriends:
                startActivity(new Intent(getActivity(), FriendsActivity.class));
                break;
            case R.id.care_linMore:
                startActivity(new Intent(getActivity(), SearchActivity.class));
                break;
        }
    }
}
